João Távora [Mon, 13 Jul 2020 22:59:41 +0000 (23:59 +0100)]
Use a hash-table for storing resolved completions
* eglot.el (eglot-completion-at-point): use a hash-table for
storing resolved completions.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/510
João Távora [Mon, 13 Jul 2020 22:43:35 +0000 (23:43 +0100)]
Reload eldoc if needed on emacs < 28
ElDoc is preloaded in Emacs, so `require`-ing won't guarantee we are
using the latest version from GNU Elpa when we load eglot.el. Use an
heuristic to see if we need to `load` it in Emacs < 28.
* eglot.el (Package-Requires): Require eldoc 1.5.0
(top): Sometimes load eldoc
João Távora [Fri, 10 Jul 2020 16:41:43 +0000 (00:41 +0800)]
Fix sorting of completion items
This fixes a problem pointed out by Yuwei Tian <ibluefocus@gmail.com>.
* eglot.el (eglot-completion-at-point): Fix getting :sortText content
of the completion item.
GitHub-reference: closes https://github.com/joaotavora/eglot/issues/509
João Távora [Thu, 9 Jul 2020 23:28:19 +0000 (00:28 +0100)]
* eglot.el (package-requires): require flymake 1.0.9 and eldoc 1.2.0
João Távora [Wed, 3 Jun 2020 17:40:58 +0000 (18:40 +0100)]
Delegate "hover" and "signature" doc synchronization efforts to eldoc
Uses Eldoc's eldoc-documentation-functions variable. In Eldoc v1.0.0
that variable was already available as a way of handling/composing
multiple docstrings from different sources, but it didn't work
practically with mutiple concurrent async sources. This was fixed in
1.1.0, which Eglot now requires.
This fixes the synchronization problems reported in https://github.com/joaotavora/eglot/issues/494 and also
issue https://github.com/joaotavora/eglot/issues/439. It is likely that some of the exact doc-composing
functionality in Eglot, (developed during those issues) was lost, and
has to be remade, quite likely in Eldoc itself.
Flymake is now also an Eldoc producer, and therefore the problems of
github issues https://github.com/joaotavora/eglot/issues/481 and https://github.com/joaotavora/eglot/issues/454 will also soon be fixed as soon as Eglot
starts using the upcoming Flymake 1.0.9.
* NEWS.md: New entry.
* README.md (eglot-put-doc-in-help-buffer)
(eglot-auto-display-help-buffer): Remove mention to these options.
* eglot.el
(Package-Requires:) Require eldoc.el 1.1.0.
(eglot--when-live-buffer): Rename from eglot--with-live-buffer.
(eglot--when-buffer-window): New macro.
(eglot--after-change, eglot--on-shutdown, eglot-ensure): Use eglot--when-live-buffer.
(eglot--managed-mode): Use eglot-documentation-functions and eldoc-documentation-strategy.
(eglot--highlights): Move down.
(eglot-signature-eldoc-function, eglot-hover-eldoc-function)
(eglot--highlight-piggyback): New eldoc functions.
(eglot--help-buffer, eglot--update-doc)
(eglot-auto-display-help-buffer, eglot-put-doc-in-help-buffer)
(eglot--truncate-string, eglot-doc-too-large-for-echo-area)
(eglot-help-at-point): Remove all of this.
(eglot--apply-workspace-edit): Call eldoc manually after an edit.
(eglot-mode-map): Remap display-local-help to eldoc-doc-buffer
João Távora [Sun, 31 May 2020 10:49:51 +0000 (11:49 +0100)]
Fix small problems around eglot's help buffer
Specifically:
- correctly format the message shown to the user about doc being truncated
- don't show message if the buffer is showing in some frame's window
- correctly name the help buffer switched to with `C-h .'.
This is still not ideal:
- When the `C-h .' suggestion is shown to the user, typing that keybinding
shouldn't result in a new LSP request to fetch probably the same info;
- All this functionality belongs in eldoc.el.
* eglot.el (eglot-help-at-point): Fix buffer name.
(eglot--update-doc): Provide more help.
Andrii Kolomoiets [Wed, 13 May 2020 07:48:26 +0000 (10:48 +0300)]
Simplify eglot-code-actions
If no region is active, ask for code actions at point, even if there
are no diagnostics at point.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-code-actions): Simplify.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/473
Andrii Kolomoiets [Tue, 26 May 2020 20:03:39 +0000 (23:03 +0300)]
Use filter-buffer-substring to get buffer text
This way modes used to represent hover info text, such as
gfm-view-mode can e.g. filter out invisible text by providing own
`filter-buffer-substring-function'.
* eglot.el (eglot--format-markup): Use `filter-buffer-substring'.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/482
João Távora [Mon, 25 May 2020 10:18:21 +0000 (11:18 +0100)]
Replace uses of project-roots with project-root
* eglot.el (Package-Requires): Require project 0.3.0.
(eglot--connect, eglot-handle-request)
(eglot-initialization-options, eglot--eclipse-jdt-contact): Use
project-root.
Gary Oberbrunner [Tue, 26 May 2020 13:13:44 +0000 (14:13 +0100)]
Also consider label of a completionitem for snippets
Copyright-paperwork-exempt: yes
* eglot.el (eglot-completion-at-point): Consider label when
expanding snippets.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/480
Andrii Kolomoiets [Wed, 6 May 2020 19:06:35 +0000 (22:06 +0300)]
Rework computation of string given to eldoc (again)
Co-authored-by: Andreii Kolomoiets <andreyk.mad@gmail.com>
Also do some refactoring to join similar logic in
eglot-doc-too-large-for-echo-area and eglot--truncate-string.
* eglot.el (eglot-doc-too-large-for-echo-area): Now returns the
number of lines available.
(eglot--truncate-string): New helper.
(eglot--first-line-of-doc, eglot--top-lines-of-doc): Remove.
(eglot--update-doc): Use new helpers.
* eglot-tests.el (hover-multiline-doc-locus): New test
GitHub-reference: close https://github.com/joaotavora/eglot/issues/459
Philipp Stephani [Mon, 25 May 2020 09:30:32 +0000 (11:30 +0200)]
Fix type error in eglot--xref-make-match
Its first argument is passed to xref-make-match, which expects a string
as its SUMMARY argument, but symbol-at-point returns a symbol.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--lsp-xrefs-for-method): use symbol-name.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/488
Rudolf Schlatte [Thu, 21 May 2020 09:20:41 +0000 (11:20 +0200)]
Add support for erlang_ls
* README.md: Mention erlang_ls
* eglot.el (eglot-server-programs): Add erlang_ls
GitHub-reference: close https://github.com/joaotavora/eglot/issues/471
João Távora [Mon, 18 May 2020 12:10:13 +0000 (13:10 +0100)]
Correctly place diagnostics in narrowed buffers
* eglot.el (eglot--lsp-position-to-point)
(eglot-handle-notification): save-restriction and widen
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/479
João Távora [Thu, 14 May 2020 22:10:48 +0000 (23:10 +0100)]
Require xref, project and eldoc from gnu elpa
* Makefile (ELPADEPS): Install Xref, Project and Eldoc.
* eglot.el (Package-Requires): Require Xref, Project and Eldoc
from GNU ELPA.
Dan Davison [Thu, 14 May 2020 00:06:35 +0000 (20:06 -0400)]
Prompt for executable if supplied name does not exist
* eglot.el (eglot--guess-contact): Interpret a list containing a
single string as an executable when forming the interactive prompt.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/474
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/478
Dan Davison [Tue, 12 May 2020 15:50:56 +0000 (11:50 -0400)]
Don't call flymake report function if flymake is disabled
Also fix https://github.com/joaotavora/eglot/issues/472.
Copyright-paperwork-exempt: yes
* eglot.el (eglot-handle-notification): Check that flymake-mode is
active before calling flymake report function.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/468
Tobias Rittweiler [Thu, 7 May 2020 22:51:44 +0000 (00:51 +0200)]
Fix "free variable" warning
* eglot.el (eglot-events-buffer): Use `eglot-current-server' instead
of `eglot--cached-server' because the latter is declared later in
the file.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/460
Andrii Kolomoiets [Wed, 6 May 2020 21:35:48 +0000 (00:35 +0300)]
Remove trailing whitespaces
* eglot.el (defvar company-backends, eglot-code-actions):
Remove trailing whitespace
João Távora [Sun, 3 May 2020 20:59:29 +0000 (21:59 +0100)]
Simplify bug-reporting instructions
We assume the user has a recent enough jsonrpc.el that consolidates
events and stderr int the same transcript.
* README.md (Reporting bugs): Simplify instructions.
* eglot.el (eglot-events-buffer): Can work with no server.
João Távora [Sun, 3 May 2020 20:37:42 +0000 (21:37 +0100)]
Survive hover responses with empty markdown strings
* eglot.el (eglot-help-at-point): Protect against null eglot--hover-info
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/433
João Távora [Sun, 3 May 2020 20:10:05 +0000 (21:10 +0100)]
Remap display-local-help (c-h .) to eglot-help-at-point
* eglot.el (eglot-help-at-point): Fallback to display-local-help if no
hover doc
(eglot-mode-map): Remap display-local-help to eglot-help-at-point..
GitHub-reference: per https://github.com/joaotavora/eglot/issues/437
Theodor Thornhill [Sun, 3 May 2020 09:20:27 +0000 (11:20 +0200)]
Tweak handling of eldoc-echo-area-use-multiline-p
Also close https://github.com/joaotavora/eglot/issues/453
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--first-line-of-doc): New helper.
(eglot--update-doc): Tweak docstring. Simplify.
(eglot-put-doc-in-help-buffer): Tweak docstring
GitHub-reference: per https://github.com/joaotavora/eglot/issues/443
João Távora [Sun, 3 May 2020 00:00:04 +0000 (01:00 +0100)]
Fontify markdown source code blocks by default
* eglot.el (eglot--format-markup): Set
markdown-fontify-code-blocks-natively to t locally.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/408
Felicián Németh [Sat, 11 Jan 2020 18:08:59 +0000 (19:08 +0100)]
Declare markdown support iff gfm-view-mode installed
* eglot.el (eglot-client-capabilities): Support markdown only when
gfm-view-mode is installed.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/408
Theodor Thornhill [Wed, 29 Apr 2020 08:09:24 +0000 (10:09 +0200)]
Always string-trim markup
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el: (eglot--format-markup): Factor string trim out
so we string-trim for all cases
GitHub-reference: close https://github.com/joaotavora/eglot/issues/450
João Távora [Sat, 2 May 2020 23:43:00 +0000 (00:43 +0100)]
Kind of honour eldoc-echo-area-use-multiline-p
A reworking of an idea and original implementation by Andrii
Kolomoiets <andreyk.mad@gmail.com>. It doesn't honor it completely
because the semantics for a non-t, non-nil value are tricky. And we
don't always exactly know what the symbol prefix reliably.
* eglot.el (eglot--update-doc): Kind of honour
eldoc-echo-area-use-multiline-p.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/443
Dan Davison [Fri, 1 May 2020 00:04:24 +0000 (20:04 -0400)]
Unbreak eglot--guess-contact for host-and-port case
* eglot.el (eglot--guess-contact): Fix bug in (host port) connection
case.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/446
Dan Davison [Sun, 26 Apr 2020 02:26:14 +0000 (22:26 -0400)]
Tweak docstring of eglot-server-programs
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-server-programs): Fix typos and phrasing.
Ingo Lohmar [Fri, 20 Sep 2019 16:39:23 +0000 (18:39 +0200)]
Support hierarchical documentsymbol in eglot-imenu
A reworking of an original implementation by Ingo Lohmar
<ingo.lohmar@github.com>
* eglot.el (eglot-client-capabilities, defvar): Add
DocumentSymbol.
(eglot-client-capabilities): Add
:hierarchicalDocumentSymbolSupport.
(eglot--parse-DocumentSymbol): Remove.
(eglot-imenu): Rewrite.
* NEWS.md (1.7): Mention new feature
GitHub-reference: close https://github.com/joaotavora/eglot/issues/303
João Távora [Sat, 2 May 2020 09:30:28 +0000 (10:30 +0100)]
Also check types when destructuring lsp objects
The problem in this issue is that the disambiguation between Command
and CodeAction objects can only be performed by checking the types of
the keys involved. So we added that to the spec and check it at
runtime.
* eglot.el (eglot--lsp-interface-alist): Add types to
Command. Tweak docstring.
(eglot--check-object): Renamed from eglot--call-with-interface.
(eglot--ensure-type): New helper.
(eglot--interface): New helper.
(eglot--check-dspec): Renamed from eglot--check-interface.
(eglot--dbind): Simplify.
(eglot-code-actions): Adjust indentation.
* eglot-tests.el (eglot-dcase-issue-452): New test.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/452
Andrii Kolomoiets [Thu, 23 Apr 2020 07:44:12 +0000 (10:44 +0300)]
Hide eldoc-message on empty hover info
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-eldoc-function): Pass nil to eglot--update-doc
on empty hover info.
(eglot--update-doc): Skip update eglot help buffer if string
is nil.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/439
Tobias Rittweiler [Sun, 26 Apr 2020 15:30:11 +0000 (17:30 +0200)]
Tests: print contents of *eglot ...* buffers in batch mode.
Useful for the CI on github. To be able to see more of the context of
a failure.
* eglot.el (eglot-server-initialized-hook): Changed semantics. Now
called when an instance of `eglot-lsp-server' is created as part of
the "connect to server" flow. Previously, there was no difference
between this hook and `eglot-connect-hook' which continues to be run
once a connection was successfully established. The
`eglot-server-initialized-hook' will now capture ALL server instances
including those that failed to be started. This change was necessary
to make the test suite be able to dump the output of processes that
fail to start when running the test suite in batch mode ("make check"
and the CI.) In PR https://github.com/joaotavora/eglot/issues/448 it was decided that it is ok to change the
semantics of this hook rather than introducing a new hook.
(eglot--connect): Change place of where the hook is run.
(eglot-connect-hook): Initialized now with
`eglot-signal-didChangeConfiguration' which was kept in
`eglot-server-initialized-hook' before.
* eglot-tests.el (eglot--call-with-fixture): Use
`eglot-server-initialized-hook' rather than `eglot-connect-hook'. And
dump the contents of the *EGLOT ...* buffers when run in
`noninteractive' (i.e. batch) mode.
(eglot--cleanup-after-test): New auxiliary function. Extracted
verbatim out of `eglot--call-with-fixture` in order to lower the
latter's LOC.
Trevor Murphy [Fri, 24 Apr 2020 18:52:01 +0000 (11:52 -0700)]
Create match xrefs when possible
"Match xrefs" are created with `xref-make-match' instead of
`xref-make'. Match xrefs support `xref-query-replace-in-results' from
the results buffer.
* eglot.el (eglot--xref-make-match): Calculate xref match length from
the eglot range.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/435
João Távora [Fri, 24 Apr 2020 15:33:36 +0000 (16:33 +0100)]
* eglot.el (eglot-put-doc-in-help-buffer): tiny docstring fix.
João Távora [Fri, 24 Apr 2020 14:39:16 +0000 (15:39 +0100)]
Don't reupdate help buffer if already rendered
* eglot.el (eglot--update-doc): Don't reupdate if doc buffer
already exists.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/445
Andrii Kolomoiets [Thu, 23 Apr 2020 20:41:22 +0000 (23:41 +0300)]
Use text-mode for plaintext markup
* eglot.el (eglot--format-markup): Use text-mode for
plaintext markup.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/444
Felicián Németh [Tue, 21 Jan 2020 18:35:34 +0000 (19:35 +0100)]
Update dependencies and copyright years
* eglot.el: Update dependencies and copyright years.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/413
Theodor Thornhill [Fri, 3 Jan 2020 20:42:08 +0000 (21:42 +0100)]
Simplify a bit of code
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-move-to-lsp-abiding-column): use
already existing function to refer to lsp-abiding-column
GitHub-reference: close https://github.com/joaotavora/eglot/issues/397
João Távora [Thu, 16 Apr 2020 09:31:01 +0000 (10:31 +0100)]
* eglot.el (version): bump to 1.6
* NEWS.md: Bump to 1.6
Felicián Németh [Sun, 19 Jan 2020 10:13:20 +0000 (11:13 +0100)]
Abide by lsp when reporting and moving to columns
* eglot.el (eglot-current-column-function): Set to
eglot-lsp-abiding-column.
(eglot-move-to-column-function): Set to
eglot-move-to-lsp-abiding-column.
* NEWS.md: Log the change here as well.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/361
João Távora [Sun, 19 Jan 2020 10:02:55 +0000 (11:02 +0100)]
Fix eglot-move-to-lsp-abiding-column ()
Ensure conformance with the this part of the specification: "if the
character value is greater than the line length it defaults back to
the line length."
* eglot.el: (eglot-move-to-lsp-abiding-column): Don't move beyond
line-end.
GitHub-reference: https://github.com/joaotavora/eglot/issues/361
Felicián Németh [Thu, 16 Apr 2020 07:38:31 +0000 (09:38 +0200)]
Send shutdown and exit messages without arguments
Fix regression introduced in
70e6157b (https://github.com/joaotavora/eglot/issues/315). According to the
LSP specification the exit notification and the shutdown request
shouldn't have arguments ("params: void"). Note that jsonrpc.el
send nil as null on the wire.
* eglot.el (eglot-shutdown): Change back the arguments of
:shutdown and :exit to nil.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/430
Felicián Németh [Fri, 20 Mar 2020 08:42:44 +0000 (09:42 +0100)]
Ignore empty hover info
This just mimics a similar check in `eglot-help-at-point'.
* eglot.el (eglot-eldoc-function): Check emptiness of `contents' more
carefully.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/425
Felicián Németh [Fri, 22 Nov 2019 17:35:01 +0000 (18:35 +0100)]
Make a public reader for project-nickname
Close https://github.com/joaotavora/eglot/issues/399.
* eglot.el (eglot-lsp-server): Add a public reader for
project-nickname as eglot-project-nickname.
(eglot--connect, eglot--read-server, eglot--mode-line-format): Use
the public variant.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/354
Felicián Németh [Fri, 22 Nov 2019 15:55:04 +0000 (16:55 +0100)]
Add public hook eglot-managed-mode-hook
Per https://github.com/joaotavora/eglot/issues/354.
* eglot.el (eglot-managed-p): New function.
(eglot--managed-mode-hook): Obsolete it.
(eglot-managed-mode-hook): New hook variable.
(eglot--managed-mode): Run the new hook.
* README.md (Customization): Mention the new hook.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/182
Vladimir Panteleev [Tue, 19 Nov 2019 02:04:43 +0000 (02:04 +0000)]
Introduce and use eglot--{}, the empty json object
* eglot.el (Constants): Add eglot--{}.
(eglot-shutdown, eglot--connect): Use it.
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/315
Vladimir Panteleev [Sun, 6 Oct 2019 16:10:32 +0000 (16:10 +0000)]
Call shutdown/exit methods with params:{}, not null
"null" is not a valid JSON value for "params" according to the
JSON-RPC specification.
* eglot.el (eglot-shutdown): Do the same thing as for "initialized",
and use an empty hash table to be serialized to {}.
Copyright-paperwork-exempt: yes
GitHub-reference: per https://github.com/joaotavora/eglot/issues/315
Felicián Németh [Thu, 9 Jan 2020 18:28:08 +0000 (13:28 -0500)]
Support bug-reference-prog-mode
* eglot.el (Local Variables): Add bug-reference-bug-regexp and
bug-reference-url-format.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/405
Felicián Németh [Wed, 8 Jan 2020 17:02:07 +0000 (18:02 +0100)]
Revert the last change about column calculation
Felicián Németh [Wed, 8 Jan 2020 15:51:09 +0000 (16:51 +0100)]
Document the changes in column calculation
* eglot.el (eglot-current-column-function)
(eglot-move-to-column-function): Document the change of the
default value.
* NEWS.md: Log the change here as well.
João Távora [Fri, 29 Nov 2019 23:42:58 +0000 (23:42 +0000)]
Abide by lsp when reporting and moving to columns
* eglot.el (eglot-current-column-function): Set to
eglot-lsp-abiding-column.
(eglot-move-to-column-function): Set to
eglot-move-to-lsp-abiding-column.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/361
Felicián Németh [Sun, 5 Jan 2020 13:32:15 +0000 (08:32 -0500)]
Merge pull request from joaotavora/scratch/fix-277-exit-notification
Fix https://github.com/joaotavora/eglot/issues/277: Send exit as a notification
GitHub-reference: https://github.com/joaotavora/eglot/issues/400
Felicián Németh [Sat, 4 Jan 2020 15:55:00 +0000 (16:55 +0100)]
Send exit as a notification
This is what the specification requires. @PerMildner, thanks for
reporting and analyzing the issue.
* eglot.el (eglot-shutdown): Use `notify' instead of `request' for the
`exit' LSP method.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/277
João Távora [Wed, 1 Jan 2020 22:05:29 +0000 (22:05 +0000)]
Avoid double shutdowns and simplify shutdown logic
* eglot.el (eglot-shutdown): Don't turn off eglot--managed-mode here.
(eglot--on-shutdown): Rather here, but without autoshutdown.
(eglot--managed-mode): Don't check eglot--shutdown-requested.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/389
Theodor Thornhill [Thu, 2 Jan 2020 09:33:26 +0000 (10:33 +0100)]
Use completing-read in eglot-code-actions
See also https://github.com/joaotavora/eglot/issues/386.
* eglot.el (eglot-code-actions): Replace tmm with completing-read
Copyright-paperwork-exempt: yes
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/393
Evgeni Kolev [Mon, 30 Dec 2019 09:13:08 +0000 (11:13 +0200)]
* eglot.el (eglot-eldoc-function): fix outdated docstring.
Fix https://github.com/joaotavora/eglot/issues/387
Steve Purcell [Sat, 28 Dec 2019 13:08:19 +0000 (02:08 +1300)]
Add elm-language-server as the language server for elm
* README.md (Connecting to a server): Add elm-language-server
* eglot.el (eglot-server-programs): Add elm-language-server
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/383
Theodor Thornhill [Thu, 26 Dec 2019 08:39:33 +0000 (09:39 +0100)]
New eglot-confirm-server-initiated-edits defcustom
* eglot.el (eglot-confirm-server-initiated-edits): New defcustom.
Copyright-paperwork-exempt: yes
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/382
Augusto Stoffel [Wed, 18 Dec 2019 12:44:28 +0000 (13:44 +0100)]
Add built-in support for tex and friends
plain-tex-mode and latex-mode are derived from tex-mode. Some other
TeX-related modes are not, so they require an explicit mention in
eglot-server-programs.
* README.md (Connecting to a server): Add Digestif to the list
* eglot.el (eglot-server-programs): Add Digestif for TeX-related modes
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/379
Antoine Kalmbach [Tue, 17 Dec 2019 19:34:29 +0000 (21:34 +0200)]
Add metals as the language server for scala
* README.md (Connecting to a server): Add metals to the list
* eglot.el (eglot-server-programs): Add metals for scala-mode
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/376
João Távora [Sat, 30 Nov 2019 00:16:12 +0000 (00:16 +0000)]
Allow non-standard keys in textdocument/publishdiagnostics.
* eglot.el (eglot-handle-notification): Allow other keys for
textDocument/publishDiagnostics.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/357
João Távora [Fri, 29 Nov 2019 23:33:12 +0000 (23:33 +0000)]
Unbreak window/showmessagerequest
* eglot.el (eglot-handle-request): Answer with a proper
MessageActionItem.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/362
João Távora [Wed, 20 Nov 2019 22:55:29 +0000 (22:55 +0000)]
Resolve compilation warnings
* eglot.el (company-tooltip-align-annotations): Forward declare.
(eglot--cached-server): Renamed from eglot--cached-current-server.
(eglot--managed-mode, eglot-current-server)
(eglot--current-server-or-lose)
(eglot--maybe-activate-editing-mode): use it.
(eglot-completion-at-point): Don't use insertTextFormat.
João Távora [Wed, 20 Nov 2019 22:51:42 +0000 (22:51 +0000)]
Locally tweak imenu-create-index-function
* eglot.el (eglot--managed-mode): locally tweak
imenu-create-index-function.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/351
Felicián Németh [Mon, 18 Nov 2019 11:23:37 +0000 (12:23 +0100)]
Fail when eglot-find-* finds no references
* eglot.el (eglot--lsp-xref-helper): Display message when no
references have been found instead of calling xref-find-references.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/339
Xu Chunyang [Sun, 17 Nov 2019 13:17:47 +0000 (21:17 +0800)]
Waste less space in completion annotations
* eglot.el (eglot-completion-at-point): don't add "(snippet)"
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/349
João Távora [Sun, 17 Nov 2019 13:07:08 +0000 (13:07 +0000)]
* eglot.el (eglot-completion-at-point): remove spurious unrelated change.
João Távora [Fri, 15 Nov 2019 16:04:55 +0000 (16:04 +0000)]
Ensure process starts in project's root
Also fix https://github.com/joaotavora/eglot/issues/347.
* eglot.el (eglot--connect): Bind default-directory around make
process.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/330
João Távora [Tue, 12 Nov 2019 08:51:09 +0000 (08:51 +0000)]
Let other imenu functions work if lsp server's doesn't
* eglot.el (eglot--stay-out-of-p): New helper.
(eglot--setq-saving): Use it.
(eglot--managed-mode): Use add-function :before-until for
imenu-create-index-function.
(eglot-imenu): Don't error. Fix indentation.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/343
Felicián Németh [Tue, 12 Nov 2019 12:50:11 +0000 (13:50 +0100)]
Support serverinfo of lsp 3.15.0
Add support for serverInfo from the upcoming specification. This
changeset just stores the info sent by the server and slightly changes
a greeting message. But it opens up the possibility to identify
servers even when eglot uses a TCP connection and therefore makes
possible to implement server specific features (in eglot-x).
Old message:
```
Connected! Server `EGLOT (test-ccls/c++-mode)' now managing `c++-mode' buffers in project `test-ccls'.
```
New message:
```
Connected! Server `ccls' now managing `c++-mode' buffers in project `test-ccls'.
```
* eglot.el (eglot--lsp-interface-alist): Extend it with serverInfo.
(eglot-lsp-server): Add member variable server-info.
(eglot--connect): Store server-info and display server's name
when connected.
r-zip [Tue, 12 Nov 2019 18:44:01 +0000 (13:44 -0500)]
Set nobreak-char-display to nil in *eglot-help*
* eglot.el (eglot-help-at-point): set nobreak-char-display
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/345
João Távora [Wed, 6 Nov 2019 15:11:12 +0000 (15:11 +0000)]
Protect against empty-string inserttext in completions
* eglot.el (eglot-completion-at-point): Don't use insertText as a
proxy.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/341
João Távora [Sat, 9 Nov 2019 22:58:08 +0000 (22:58 +0000)]
Provide stable eglot-current-server helper
It's better if eglot--current-server is removed, since it was being
abused by other packages, and has side effects. The only place where
it was really needed was eglot--maybe-activate-editing-mode, so the
find-and-cache logic has been moved there. All other places that can
handle a nil server now use eglot-current-server, the external
version.
* eglot.el (eglot-shutdown, eglot, eglot--read-server)
(eglot--mode-line-format): Use eglot-current-server.
(eglot--connect): Update comment.
(eglot--current-server): Remove.
(eglot-current-server): New helper.
(eglot--maybe-activate-editing-mode): find and cache the server here.
* eglot-tests.el (auto-detect-running-server)
(auto-shutdown, auto-reconnect, eglot-ensure)
(slow-async-connection): Use eglot-current-server.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/342
João Távora [Tue, 5 Nov 2019 23:53:35 +0000 (23:53 +0000)]
Don't choke on workspace/configuration with no scopeuri
* eglot.el (eglot-handle-request): Don't choke on nil scopeUri.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/340
Ingo Lohmar [Sun, 20 Oct 2019 10:21:37 +0000 (12:21 +0200)]
Only set eglot--cached-current-server by (more aggressive) caching
* eglot.el (eglot--current-server): Always set cache value.
(eglot--maybe-activate-editing-mode): No need to set cached server.
Ingo Lohmar [Fri, 18 Oct 2019 19:19:46 +0000 (21:19 +0200)]
Simplify "maybe"-activation, dump "server" arg
* eglot.el (eglot--maybe-activate-editing-mode): Remove `server' arg.
Ingo Lohmar [Fri, 18 Oct 2019 19:11:59 +0000 (21:11 +0200)]
Merge -onoff proxy code into minor mode function
This simplifies bookkeeping and keeping the state of locally cached
servers, their managed buffers, and the buffer-local mode consistent.
The "on" case of the -onoff code now expects that
`eglot--cached-current-server' has been set already, the "off" case uses
the same value.
* eglot.el (eglot--managed-mode-onoff): Remove.
(eglot--managed-mode): Adopt code.
(eglot--managed-mode-off): New minimal wrapper.
João Távora [Wed, 30 Oct 2019 01:24:10 +0000 (01:24 +0000)]
Use completionitem/resolve more abundantly
It was already used to resolve documentation bits of completions, but
it can also be useful to resolve snippet templates and such.
To resolve a completion, you need some part of a completion to start
with. If it has a :data field exists and the server supports
:resolveProvider, fetch the new object, otherwise use whatever we had
already.
* eglot.el (eglot-completion-at-point): Add another local
function for resolving completions.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/50
Xu Chunyang [Mon, 28 Oct 2019 15:29:03 +0000 (23:29 +0800)]
Support markdown for textdocument/hover ()
* eglot.el (eglot-client-capabilities): annouce markdown support for hover.
(eglot--format-markup): Format hover info with Markdown.
Fixes: https://github.com/joaotavora/eglot/issues/328
Copyright-paperwork-exempt: yes
GitHub-reference: https://github.com/joaotavora/eglot/issues/329
Xu Chunyang [Sun, 27 Oct 2019 15:41:53 +0000 (23:41 +0800)]
Don't run mode hooks in eglot--format-markup
* eglot.el (eglot--format-markup): Use delay-mode-hooks.
Copyright-paperwork-exempt: yes
João Távora [Sat, 26 Oct 2019 21:51:57 +0000 (22:51 +0100)]
Support workspace/configuration
This helps users configure servers such as Gopls, which doesn't
support didChangeConfiguration signals.
* README.md (Per-project server configuration): New section.
* eglot.el (eglot-workspace-configuration): Fix docstring.
(eglot-signal-didChangeConfiguration): Rename a variable.
(eglot-handle-request workspace/configuration): New request
handler.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/326
João Távora [Thu, 24 Oct 2019 11:32:51 +0000 (12:32 +0100)]
Expand readme.md section on handling quirky servers
Also remove explicit cquery support (cquery seems to be dead anyway).
* README.md (Handling quirky servers): New section.
* eglot.el (eglot-initialization-options eglot-cquery): Remove.
João Távora [Tue, 22 Oct 2019 11:18:53 +0000 (12:18 +0100)]
Unbreak imenu
* eglot.el (eglot-imenu): Unbreak.
João Távora [Tue, 22 Oct 2019 00:44:54 +0000 (01:44 +0100)]
Force company to align completion annotations in eglot sessions
* eglot.el (eglot--managed-mode): force
company-tooltip-align-annotations to t.
João Távora [Mon, 21 Oct 2019 21:25:13 +0000 (22:25 +0100)]
Fix race condition when company-completing quickly
For some reason, probably related to the way that Eglot tries to
maintain the responsiveness of Company completion tooltips (see
below), the user's explicit input will sometimes be surprisingly
deleted by Company, leading to a horrible completion experience.
This is sometimes hard to reproduce, but appears to match this
description perfectly:
https://github.com/joaotavora/eglot/issues/319#issuecomment-
542955432
Fortunately, Company has a good fix for this, which is to pass
`:company-require-match 'never` in the completion-at-point function.
This is the fix applied in this commit.
However, this line shouldn't be required since the default value for
`company-require-match` is `company-explicit-action-p`, presumably
meaning that the auto-deletion should never take place for characters
typed by the user.
This points to a bug in Company, or at least something which may have
been exacerbated by the way that Eglot aggressively fetches
completions from the server by passing :cancel-on-input to
`jsonrpc-request`, discarding out-of-date replies. Perhaps that
discarding step bears with it some side-effects that make the
`company-explicit-action-p` test return `nil` instead of the correct
`t`. Company interprets this as carte blanche to delete the last
inserted character.
* eglot.el (eglot-completion-at-point): Use :company-require-match
'never.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/319
João Távora [Mon, 21 Oct 2019 15:07:38 +0000 (16:07 +0100)]
Unbreak m-x vc-revert, which reverts preserving modes
Unlike the normal revert-buffer command, vc-revert, doesn't re-apply
the major mode, meaning it was missing a didOpen to pair with the
didClose that is unconditionally sent on both commands.
Needed to use the dynamic variable revert-buffer-preserve-modes, and,
curiously, also forward-declare it to appease the byte compiler.
* eglot.el (eglot--managed-mode): Use after-revert-hook.
(revert-buffer-preserve-modes): Forward declare.
(eglot--after-revert-hook): Signal didOpen when preserving-modes.
(eglot--maybe-activate-editing-mode): Tweak comment.
João Távora [Mon, 21 Oct 2019 12:08:45 +0000 (13:08 +0100)]
(again): fix issue with replace-buffer-contents
Manually calling the before/after change hooks for Emacs 26.1's buggy
replace-buffer-contents must be done with absolute positions, not
markers.
* eglot.el (eglot--apply-text-edits): Call change hooks with
buffer positions, not markers.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/259
João Távora [Sun, 20 Oct 2019 11:56:41 +0000 (12:56 +0100)]
* eglot.el (version): bump to 1.5
* NEWS.md: update.
João Távora [Sat, 19 Oct 2019 22:07:47 +0000 (23:07 +0100)]
Let user keep control of some variables during eglot sessions
* NEWS.md: Mention new variable eglot-stay-out-of
* eglot.el (eglot-stay-out-of): New variable.
(eglot--setq-saving): Use it.
(eglot--managed-mode): Use eglot--setq-saving for imenu. No need
to remove 'eglot-flymake-backend from diagnostic functions.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/324
João Távora [Fri, 18 Oct 2019 15:43:50 +0000 (16:43 +0100)]
Don't immediately request completions in eglot-completion-at-point
Yet another adjustment to this function. According to the
documentation of completion-at-point-functions, we should strive to
make functions like eglot-completion-at-point "cheap to run".
Requesting completion from the server immediately after calling the
function goes against that. The reason we were doing it is that it
might have helped compute more accurate "bounds" for the return value
(START and END) from possible TextEdit completion items. But I've
decided it's not worth the effort, at least for now.
* eglot.el (eglot-completion-at-point): Request completions
asynchronously.
João Távora [Wed, 16 Oct 2019 22:13:09 +0000 (23:13 +0100)]
Protect against zero-length completions
Apparently the Vue Language Server sends such things (see https://github.com/joaotavora/eglot/issues/319).
* eglot.el (eglot-completion-at-point): Protect against
zero-length completions.
João Távora [Wed, 16 Oct 2019 18:25:51 +0000 (19:25 +0100)]
Don't choke on single-location reply to td/definition
* eglot.el (eglot--lsp-xrefs-for-method): Accept non-vector
Location.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/321
João Távora [Wed, 16 Oct 2019 15:46:03 +0000 (16:46 +0100)]
Unbreak eglot--setq-saving if symbol is unbound
* eglot.el (eglot--setq-saving): check if symbol is bound
João Távora [Wed, 16 Oct 2019 15:29:41 +0000 (16:29 +0100)]
Use of company-capf backend in eglot-managed buffers
* eglot.el (company-backends): forward-declare
(eglot--managed-mode): Force company-backends to company-capf
João Távora [Wed, 16 Oct 2019 13:16:52 +0000 (14:16 +0100)]
Play along with lsp's filtertext hacks
Reworked important parts of eglot-completion-at-point.
One of the tasks was to cleanup the nomenclature so it's easier to
spot how LSP and Emacs's views of completion techniques differ. When
reading this rather long function, remember an "item" is a plist
representing the LSP completionItem object, and "proxy" is a
propertized string that Emacs's frontends will use to represent that
completion. When the completion is close to done, the :exit-function
is called, to potentially rework the inserted text so that the final
result might be quite different from the proxy (it might be a snippet,
or even a suprising text edit).
The most important change in this commit reworks the way the
completion "bounds" are calculated in the buffer. This is the region
that Emacs needs to know that is being targeted for the completion. A
server can specify this region by using textEdit-based completions all
consistently pointing to the same range. If it does so, Emacs will
use that region instead of its own understanding of symbol
boundaries (provided by thingatpt.el and syntax tables).
To implement server-side completion filtering, the server can also
provide a filterText "cookie" in each completion, which, when
prefix-matched to the intended region, selects or rejects the
completion. Given the feedback in
https://github.com/microsoft/language-server-protocol/issues/651, we
have no choice but to play along with that inneficient and grotesque
strategy to implement flex-style matching. Like ever in LSP, we do so
while being backward-compatible to all previously supported behaviour.
* eglot.el (eglot-completion-at-point): rework.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/235
João Távora [Wed, 16 Oct 2019 08:49:09 +0000 (09:49 +0100)]
Always filter completions client-side by prefix
Prefix completion is all we get in LSP because there are some servers
that send *all* completions everytime. This is horrible, but it's the
currently defined behaviour. See
https://github.com/microsoft/language-server-protocol/issues/651.
* eglot.el (eglot-completion-at-point): Use all-completions.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/319
João Távora [Tue, 15 Oct 2019 17:42:33 +0000 (18:42 +0100)]
Fix bug in workspace/didchangewatchedfiles
* eglot.el (eglot-register-capability): Fix a bug and a couple of
warnings.
Tom Tromey [Tue, 15 Oct 2019 16:32:57 +0000 (10:32 -0600)]
Add support for the ada language server
* eglot.el (eglot-server-programs): Add ada-mode entry.
* README.md (Connecting to a server): Add Ada entry.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/316
João Távora [Sat, 12 Oct 2019 00:57:00 +0000 (01:57 +0100)]
Fix eglot-completion-at-point to work with bare completion-at-point
Fixes https://github.com/joaotavora/eglot/issues/313, fixes https://github.com/joaotavora/eglot/issues/311, fixes https://github.com/joaotavora/eglot/issues/279
As is well known, LSP's and Emacs's completion mechanics don't fit
very well together, mostly because Emacs expects completion to be a
something of a pure function of a string argument and LSP treats as a
function of a concrete buffer position.
A further complication arises because some completion frontends like
"bare" completion-at-point make Emacs modify the buffer's contents
during the completion process, while other (notably company-mode)
don't do that. Thus, 'eglot-completion-at-point' must take extra care
to answer to the questions listed in the "(elisp)Programmed
Completion" info node based on its (quite hacky) "completions" local
var and _not_ based on the intermediate buffer contents. That var is
also used to cache the last LSP response and allow the :exit-function
callback to retrieve much more than just the completion text in
In yet another related problem, :exit-function won't be called at all
with completion-at-point if the completion table doesn't answer
properly to test-completion. A previous use of
completion-table-dynamic was found to be unsuitable here: we must
answer all the requests separately.
* eglot.el (eglot-completion-at-point): Rework.